package pdn.sci.cs.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import pdn.sci.cs.entity.ChildSponsor;

@Repository
public class ChildSponsorDao extends GenericDao<ChildSponsor> {

	private static final Class<ChildSponsor> clazz = ChildSponsor.class;

	public List<ChildSponsor> findByChildId(String childId) {

		DetachedCriteria criteria = createCriteria(clazz);

		if(childId != null) {
			criteria.add(Restrictions.eq(ChildSponsor.CHILD_ID, childId));
			return findByCriteria(criteria);

		} else {
			return new ArrayList<ChildSponsor>(0);
		}

	}

	public List<ChildSponsor> findBySponsorId(String sponsorId) {

		DetachedCriteria criteria = createCriteria(clazz);

		if(sponsorId != null) {
			criteria.add(Restrictions.eq(ChildSponsor.SPONSER_ID, sponsorId));
			return findByCriteria(criteria);

		} else {
			return new ArrayList<ChildSponsor>(0);
		}

	}

}
